<!-- head -->
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-md-12">
        <ol class="breadcrumb">
            <li><a>主页</a></li>
            <li><a>超级盟主</a></li>
            <li class="active"><strong>商品修改</strong></li>
        </ol>
    </div>
</div>

<!-- content-->
<div class="wrapper wrapper-content animated fadeIn" ng-controller="goodAllAgentEditCtrl">
    <form class="form-horizontal" id="form1" name="horizontalCard">
        <div class="form-group">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <div class="row">
                        <div class="ibox-title">
                            <h5>基本资料</h5>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><i class="red_req">*</i>商品标题:</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="goodsName" required ng-model="addInfo.goodsName" maxlength="60">
                                <div class="req_mesg" ng-show="horizontalCard.goodsName.$dirty && horizontalCard.goodsName.$invalid">
                                    <span ng-show="horizontalCard.goodsName.$error.required">商品标题不能为空</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><i class="red_req">*</i>起购量:</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="minimum" required ng-model="addInfo.minimum" ng-pattern="/^\d+$/" >
                                <div class="req_mesg" ng-show="horizontalCard.minimum.$dirty && horizontalCard.minimum.$invalid">
                                    <span ng-show="horizontalCard.minimum.$error.required">起购量不能为空</span>
                                    <span ng-show="horizontalCard.minimum.$error.pattern">起购量格式不符</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><i class="red_req">*</i>按起购量的倍数下单:</label>
                            <div class="col-sm-5">
                                <label><input type="radio" ng-model='addInfo.isMulti' name="finance"  ng-value="0"/>否</label>
                                &nbsp;&nbsp;&nbsp;&nbsp;
                                <label><input type="radio" ng-model='addInfo.isMulti' name="finance"  ng-value="1"/>是</label>
                                &nbsp;&nbsp;&nbsp;&nbsp;
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><i class="red_req">*</i>所属品牌:</label>
                            <div class="col-sm-3">
                                <select class="form-control" ng-model="addInfo.brandCode" ng-change="goodsGroupQuery();" required ng-options="x.value as x.text for x in oemList"/>
                                <div class="req_mesg" ng-show="horizontalCard.brandCode.$dirty && horizontalCard.brandCode.$invalid">
                                    <span ng-show="horizontalCard.brandCode.$error.required">所属品牌不能为空</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><i class="red_req">*</i>商品分类:</label>
                            <div class="col-sm-3">
                                <select class="form-control" ng-model="addInfo.groupCode" ng-options="x.value as x.text for x in goodsGroupList" required/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><i class="red_req">*</i>商品规格:</label>
                            <div class="col-lg-10" >
                                <button class="btn btn-primary5 btn-mr20" type="button" ng-click="addModal()">添加</button>
                                <button class="btn btn-primary btn-mr20"  type="button" ng-click="delteData()">删除</button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-lg-1 control-label"></label>
                            <div class="col-lg-9">
                                <div style="height:300px"  ui-grid="formatGrid" ui-grid-selection ui-grid-resize-columns ui-grid-pinning></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><i class="red_req">*</i>商品类型:</label>
                            <div class="col-sm-3">
                                <select class="form-control" ng-model="addInfo.shipWay" required ng-options="x.value as x.text for x in shipWayes"/>
                                <div class="req_mesg" ng-show="horizontalCard.shipWay.$dirty && horizontalCard.shipWay.$invalid">
                                    <span ng-show="horizontalCard.shipWay.$error.required">商品类型不能为空</span>
                                </div>
                            </div>
                        </div>
                        <div class="ibox-title">
                            <h5>商品主图</h5>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <label class="col-sm-7" style="color:red;margin-top:7px;">注:商品主图最少上传1张，最多上传3张，支持jpg、png格式</label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">图1:</label>
                            <div class="col-sm-4" ng-if="imgUrl!=null&&imgUrl!=''">
                                <div class="col-img">
                                    <a href="{{imgUrl}}" fancybox rel="group">
                                        <img width="250px" height="150px" ng-src="{{imgUrl}}"/>
                                    </a>
                                </div>
                            </div>
                            <label class="col-sm-2 control-label">图2:</label>
                            <div class="col-sm-4" ng-if="imgUrl2!=null&&imgUrl2!=''">
                                <div class="col-img">
                                    <a href="{{imgUrl2}}" fancybox rel="group">
                                        <img width="250px" height="150px" ng-src="{{imgUrl2}}"/>
                                    </a>
                                </div>
                                <label style="color:red; float:left;">
                                    <button class="btn btn-new btn-mr20" ng-click="deleteImg(2)" type="button">删除图2</button>
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-4" >
                                <input type="file" nv-file-select="" uploader="uploaderImg1" multiple  />
                                <table class="table" class="col-sm-4" >
                                    <tbody>
                                    <tr ng-repeat="item in uploaderImg1.queue">
                                        <td>
                                            <div ng-show="uploaderImg1.isHTML5" ng-thumb="{ file: item._file, height: 100 }"></div>
                                        </td>
                                        <td nowrap>
                                            <button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
                                                <span class="glyphicon glyphicon-trash"></span> 删除
                                            </button>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-4" >
                                <input type="file" nv-file-select="" uploader="uploaderImg2"   multiple  />
                                <label style="color:red; float:left;"></label>
                                <table class="table" class="col-sm-4" >
                                    <tbody>
                                    <tr ng-repeat="item in uploaderImg2.queue">
                                        <td>
                                            <div ng-show="uploaderImg2.isHTML5" ng-thumb="{ file: item._file, height: 100 }"></div>
                                        </td>
                                        <td nowrap>
                                            <button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
                                                <span class="glyphicon glyphicon-trash"></span> 删除
                                            </button>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">图3:</label>
                            <div class="col-sm-4" ng-if="imgUrl3!=null&&imgUrl3!=''">
                                <div class="col-img">
                                    <a href="{{imgUrl3}}" fancybox rel="group">
                                        <img width="250px" height="150px" ng-src="{{imgUrl3}}"/>
                                    </a>
                                </div>
                                <label style="color:red; float:left;">
                                    <button class="btn btn-new btn-mr20" ng-click="deleteImg(3)" type="button">删除图3</button>
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-4" >
                                <input type="file" nv-file-select="" uploader="uploaderImg3"   multiple  />
                                <label style="color:red; float:left;"></label>
                                <table class="table" class="col-sm-4" >
                                    <tbody>
                                    <tr ng-repeat="item in uploaderImg3.queue">
                                        <td>
                                            <div ng-show="uploaderImg3.isHTML5" ng-thumb="{ file: item._file, height: 100 }"></div>
                                        </td>
                                        <td nowrap>
                                            <button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
                                                <span class="glyphicon glyphicon-trash"></span> 删除
                                            </button>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="ibox-title">
                            <h5>商品详情</h5>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商品描述:</label>
                            <div class="col-lg-10">
                                <summernote type="text" id="summernote" class="form-control" name="goodsDesc" ng-model="addInfo.goodsDesc" on-image-upload="imageUploadALL(files)" editable="editable" editor="editor" >
                                </summernote>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商品详情图片:</label><label style="color: silver;" class="control-label">(按上传的先后位置显示)</label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">&nbsp;</label>
                            <ul id="imageUL" style="list-style-type:none" class="col-lg-10">
                                <li class="col-sm-12" style="margin: 10px auto;text-align: center;"
                                    ng-if="imgsUrl!=null && imgsUrl.length>0" data-ng-repeat="(key,value) in imgsMap"
                                    yun_name="{{key}}" id="{{key.substring(0,key.indexOf('.'))}}" oldImage="oldImage">
                                    <table class="table" class="col-sm-4" >
                                        <tbody>
                                            <tr>
                                                <td style="width: 100%;text-align: center;">
                                                    <a href="{{value}}" fancybox rel="detailImgs"><img style="width: 500px;" ng-src="{{value}}"/></a>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="width: 100%">
                                                    <button type="button" class="btn btn-danger btn-xs" ng-click="removeOldImg(key.substring(0,key.indexOf('.')))">
                                                        <span class="glyphicon glyphicon-trash"></span> 删除
                                                    </button>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </li>
                                <li ng-repeat="item in uploaderImgList.queue" class="col-sm-12" style="margin: 10px auto;text-align: center;" newImage="newImage">
                                    <table class="table" class="col-sm-4" >
                                        <tbody>
                                        <tr>
                                            <td style="width: 80%;text-align: center;">
                                                <div ng-show="uploaderImgList.isHTML5" ng-thumb="{ file: item._file, width: 500 }"></div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="width: 100%">
                                                <button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
                                                    <span class="glyphicon glyphicon-trash"></span> 删除
                                                </button>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </li>
                                <li class="col-sm-4" style="margin: 10px auto;text-align: center;height: 100px;">
                                    <input id="uploaderImg" type="file" nv-file-select="" uploader="uploaderImgList" multiple style="margin: 10px auto;display: none;" />
                                    <span class="glyphicon glyphicon-plus" style="text-align: center;font-size: 45px;width: 100px;height: 100px;line-height: 100px;border: 1px solid silver;padding-left: 5px;" onclick="$('#uploaderImg').click();"></span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-lg-12 bgff">
                <div class="col-sm-12">
                    <div class="col-lg-3"></div>
                    <div class="col-sm-6">
                        <button class="btn btn-primary btn-mr20" type="button"
                                id="btnSubmit4" ng-click="saveProduct()" ng-disabled="horizontalCard.$invalid || submitting">提交</button>
                        <a class="btn btn-primary4" ui-sref="allAgent.goodManage" >返回</a>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <div id="addModal" class="modal fade form-horizontal" tabindex="4" role="dialog">
        <div class="modal-dialog" style="height:450px;width: 900px">
            <div class="modal-content" >
                <form class="form-horizontal" name="addCard" novalidate>
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">
                            &times;</button>
                        <h3 class="modal-title">商品规格</h3>
                    </div>
                    <div class="modal-body">
                        <div class="form-group" ng-show="isSize">
                            <label class="col-sm-2 control-label"><i class="red_req">*</i>销售价:</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="price" required ng-model="baseInfo.price"
                                       ng-change="baseInfo.agio=((baseInfo.price==null?0:baseInfo.price)-(baseInfo.cost==null?0:baseInfo.cost)).toFixed(2)"  ng-pattern="/^([1-9]\d{0,9}|0)(\.\d{1,2})?$/" >
                                <div class="req_mesg" ng-show="addCard.price.$dirty && addCard.price.$invalid">
                                    <span ng-show="addCard.price.$error.required">销售价不能为空</span>
                                    <span ng-show="addCard.price.$error.pattern">成本价格式不符</span>
                                </div>
                            </div>
                            <label  class="fontClass" style="color: red">单位:元</label>
                        </div>
                        <div class="form-group" ng-show="isSize">
                            <label class="col-sm-2 control-label"><i class="red_req">*</i>成本价:</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="cost" required ng-model="baseInfo.cost"
                                       ng-change="baseInfo.agio=((baseInfo.price==null?0:baseInfo.price)-(baseInfo.cost==null?0:baseInfo.cost)).toFixed(2)"  ng-pattern="/^([1-9]\d{0,9}|0)(\.\d{1,2})?$/" >
                                <div class="req_mesg" ng-show="addCard.cost.$dirty && addCard.cost.$invalid">
                                    <span ng-show="addCard.cost.$error.required">成本价不能为空</span>
                                    <span ng-show="addCard.cost.$error.pattern">成本价格式不符</span>
                                </div>
                            </div>
                            <label  class="fontClass" style="color: red">单位:元</label>
                        </div>
                        <div class="form-group" ng-show="isSize">
                            <label class="col-sm-2 control-label"><i class="red_req">*</i>差价:</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="agio" readonly ng-model="baseInfo.agio">
                            </div>
                            <label  class="fontClass" style="color: red">单位:元</label>
                        </div>
                        <div class="form-group" ng-show="isSize">
                            <label class="col-sm-2 control-label"><i class="red_req">*</i>颜色:</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="color" required ng-model="baseInfo.color">
                                <div class="rq_mesg" ng-show="addCard.color.$dirty && addCard.color.$invalid">
                                    <span ng-show="addCard.color.$error.required">颜色不能为空</span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">尺码:</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="size" ng-model="baseInfo.size">
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <div class="form-group control-label">
                            <label class="col-sm-1 control-label"></label>
                            <div class="col-sm-6">
                                <button class="btn btn-primary btn-mr20" ng-show="modeState"  ng-disabled="addCard.$invalid" type="button" ng-click="saveModal('add')" >确定</button>
                                <button class="btn btn-primary btn-mr20" ng-show="!modeState" ng-disabled="addCard.$invalid" type="button" ng-click="saveModal('edit')" >确定</button>
                                <button class="btn btn-primary4" type="button" ng-click='cancel()'
                                >返回</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>